module.exports = class MyWebpackPlugin {

  constructor(filename = "test.js") {
    this.filename = filename;
  }

  apply(compiler) {
    compiler.hooks.emit.tap("FileListPlugin", complation => {
      const fileList = [];
      for (const key in complation.assets) {
        if (key.startsWith("spc")) {
          const content = `const spc = require('./${key}')
console.log(spc)`;
          fileList.push(content);
        }
      }

      const str = fileList.join("\n\n");
      complation.assets[this.filename] = {
        source() {
          return str
        },
        size() {
          return str.length;
        }
      }
    })
  }
}
